package com.wswy.wzcx.ui.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.text.Editable;
import android.text.TextUtils;
import android.view.View;

import com.che.libcommon.utils.ToastUtils;
import com.wswy.wzcx.ui.activity.PwdActivity;

/**
 * Created by wangduheng26 on 2018/1/22.
 * wangduheng26@gmail.com
 */

public class PreChangePwdFragment extends PwdFragment {
    public static final String TAG = "PreChangePwdFragment";

    public static PreChangePwdFragment newInstance() {

        Bundle args = new Bundle();
        PreChangePwdFragment fragment = new PreChangePwdFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        editText.setHint("请输入旧密码");
        textView.setVisibility(View.GONE);
        tvSubmit.setText("下一步");
        tvTitle.setText("旧密码");
    }


    @Override
    protected void submit() {
        final Editable text = editText.getText();

        if (!TextUtils.isEmpty(text) && !isFinish()) {
            final FragmentActivity activity = getActivity();
            if (activity instanceof PwdActivity) {
                ((PwdActivity) activity).replaceFragment(ChangePwdFragment.newInstance(String.valueOf(text)));
            }
        } else {
            ToastUtils.showText("密码为空");
        }
    }

    @Override
    public String getFragmentTitle() {
        return "修改登录密码";
    }
}
